<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en" class="no-js">
<!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
<meta charset="utf-8" />
<title>供应商管理 - 供应商列表</title>

<?php include $this->c['_homes']['_viewsHome'] . '/_global/_head.php';?>
</head>
<!-- BEGIN BODY -->
<body class="page-header-fixed page-sidebar-fixed">
<!-- BEGIN HEADER -->
<?php include $this->c['_homes']['_viewsHome'] . '/_global/head.php';?>
<!-- END HEADER -->
<div class="clearfix"></div>
<!-- BEGIN CONTAINER -->
<div class="page-container" >
  <!-- BEGIN HORIZONTAL MENU PAGE SIDEBAR1 -->
  <?php include $this->c['_homes']['_viewsHome'] . '/_global/menu.php';?>
  <!-- END BEGIN HORIZONTAL MENU PAGE SIDEBAR -->
  <!-- BEGIN PAGE -->
  <div class="page-content">
    <!-- BEGIN PAGE HEADER-->
    <div class="row">
      <div class="col-md-12">
        <!-- BEGIN PAGE TITLE & BREADCRUMB-->
        <h3 class="page-title"> 供应商列表 </h3>
        <ul class="page-breadcrumb breadcrumb">
          <?php
if ($this->pv['add']) {
    ?>
          <li class="btn-group">
            <button type="button" class="btn blue dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-delay="1000" data-close-others="true"> <span>操作</span> <i class="icon-angle-down"></i> </button>
            <ul class="dropdown-menu pull-right" role="menu">
              <li><a href="/channel/supplier_add"><i class="icon-plus"></i> 新增供应商</a></li>
            </ul>
          </li>
          <?
}
?>
          <li> <i class="icon-home"></i> <a href="/manage">后台</a> <i class="icon-angle-right"></i> </li>
          <li> 供应商管理 <i class="icon-angle-right"></i> </li>
          <li>供应商列表</li>
        </ul>
        <!-- END PAGE TITLE & BREADCRUMB-->
      </div>
    </div>
    <!-- END PAGE HEADER-->
    <!-- BEGIN PAGE CONTENT-->

    <div class="row">
      <div class="col-md-12">
        <!-- BEGIN SAMPLE TABLE PORTLET-->
        <div class="portlet box blue">
          <div class="portlet-title">
            <div class="caption"><i class="icon-list"></i>供应商列表</div>
            <div class="tools"> <a href="javascript:;" class="collapse"></a> </div>
          </div>
          <div class="portlet-body">
            <div class="table-scrollable">
             <table class="table table-striped table-bordered table-hover dataTable">
              <thead>
                <tr>
                  <th>供应商ID</th>
                  <th>供应商名称</th>
                  <th>供应商联系人</th>
                  <th>供应商地址</th>
                  <th>供应商电话</th>
                  <th>联系人电话</th>
                  <th>操作</th>
                </tr>
              </thead>
 <tbody>
               <?php
if ($this->data['data']) {
    foreach ($this->data['data'] as $k => $r) {

        ?>
                <tr>
                  <td><?=$r['id'];?></td>
                  <td><?=$r['supplier'];?></td>
                  <td><?=$r['realname'];?></td>
                  <td><?=$r['address'];?></td>
                  <td><?=$r['tel'];?></td>
                  <td><?=$r['phone'];?></td>
                  <td><?php
if ($this->pv['edit']) {
            echo ' <a href="supplier_edit?id=' . $r['id'] . '" class="btn btn-xs blue"><i class="icon-file-alt"></i> 编辑</a>';
        }

        if ($this->pv['del']) {
            echo ' <a href="#portlet-config" data-toggle="modal" onclick="_delete_alert(' . $r['id'] . ');" class="btn btn-xs red"><i class="icon-remove"></i> 删除</a>';
        }

        ?></td>
                </tr>
                <?php }}?>
              </tbody>
            </table>
          </div>
          <div style="background:#f2f2f2;text-align:right;">
            <?php
if ($this->data['maxpage'] > 1) {
    ?>
            <div >
              <ul class="pagination">
                <?
    $pquery = "?";
    if ($this->data['para']) {
        foreach ($this->data['para'] as $k => $r) {
            $pquery .= $k . "=" . $r . "&";
        }
    }

    if ($this->data['page'] > 1) {
        echo '<li><a href="' . $pquery . 'page=' . ($this->data['page'] - 1) . '"><i class="icon-angle-left"></i></a></li>';
    }

    for ($i = $this->data['spage']['ps']; $i <= $this->data['spage']['pe']; $i++) {
        if ($i == $this->data['page']) {
            echo '<li class="disabled"><a href="javascript:void(0);">' . $i . '</a></li>';
        } else {
            echo '<li><a href="' . $pquery . 'page=' . $i . '">' . $i . '</a></li>';
        }

    }

    if ($this->data['page'] < $this->data['maxpage']) {
        echo '<li><a href="' . $pquery . 'page=' . ($this->data['page'] + 1) . '"><i class="icon-angle-right"></i></a></li>';
    }

    ?>
              </ul>
            </div>
            <?
}
?>
        <!-- END SAMPLE TABLE PORTLET-->
      </div>
    </div>
    <!-- END PAGE CONTENT-->
  </div>
  <!-- END PAGE -->
</div>
<!-- END CONTAINER -->
    <!-- BEGIN SAMPLE PORTLET CONFIGURATION MODAL FORM-->
    <div class="modal fade" id="portlet-config" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
            <h4 class="modal-title">Modal title</h4>
          </div>
          <div class="modal-body"> Widget settings form goes here </div>
          <div class="modal-footer">
            <button type="button" class="btn blue submit_btn">确定</button>
            <button type="button" class="btn default" data-dismiss="modal">取消</button>
          </div>
        </div>
        <!-- /.modal-content -->
      </div>
      <!-- /.modal-dialog -->
    </div>
    <!-- /.modal -->
    <form method="post" id="_frm" action="/channel/saveSupplier">
  <input type="hidden" name="act" value="delete">
  <input type="hidden" name="dataid" id="_dataid" value="0">
</form>
<form method="post" id="_batch" action="/channel/saveSupplier">
  <input type="hidden" name="act" id="_batch_act" value="delAll">
  <input type="hidden" name="dataid" id="_batch_dataid" value="">
</form>
<?php include $this->c['_homes']['_viewsHome'] . '/_global/_footer.php';?>
<script type="text/javascript">
jQuery(document).ready(function() {
  App.init();
  jQuery('#_checkboxall').change(function () {
    var checked = jQuery(this).is(":checked");
    jQuery("._checkboxs").each(function () {
      if (checked) {
        $(this).attr("checked", true);
      } else {
        $(this).attr("checked", false);
      }
      $(this).parents('tr').toggleClass("active");
    });
    jQuery.uniform.update("._checkboxs");
  });

  $("._checkboxs").change(function() {
        var checked = jQuery(this).is(":checked");
    if (!checked) {
      $(this).attr("checked", false);
      $(this).parents('tr').removeClass("active");
      $("#_checkboxall").attr("checked",false);
      jQuery.uniform.update("#_checkboxall");
    }
    });
  $(".submit_btn").bind("click",function(){
    switch(_submit_action){
      case "delete":
        _delete_action();
      break;
    }
  });
});

var _submit_action = '',_dataid = 0;
function _delete_alert(dataid){
  _submit_action = 'delete';
  _dataid = dataid;
  $("#portlet-config .modal-title").html('删除供应商信息');
  $("#portlet-config .modal-body").html('<p>确定删除供应商信息吗？</p> <p class="alert alert-danger">警告：删除后不可恢复</p>');
}
function _delete_action(){
  $("#_dataid").prop("value",_dataid);
  $("#_frm").submit();
}

function _batch(act){
  var _ids = '';
  $("._checkboxs").each(function () {
    if( $(this).attr("checked")  ) {
      if(_ids!="") _ids +=',';
      _ids += $(this).val();
    }
  });
  if(_ids!=""){
    $("#_batch_act").prop("value",act);
    $("#_batch_dataid").prop("value",_ids);
    var _str = '';
    switch(act){
      case "delAll":
      _str = '确定删除选中的供应商信息吗？';
      break;
    }
    cm = confirm(_str);
    if(cm){
        $("#_batch").submit();
    }
  }
  else swal("至少选择一个供应商");
}
function close_news(){
    $(".modal-content").css("display","none");
    $(".modal-backdrop.fade.in").css("display","none");
 }
</script>

<!-- END JAVASCRIPTS -->
</body>
<!-- END BODY -->
</html>